home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / quartz / quartz10.lha / FTexample / bench.c next >
C/C++ Source or Header  |  1990-04-29  |  447b  |  36 lines

  1. /* Benchmark routines */
  2.  
  3. #include <stdio.h>
  4. #include "thread.h"
  5. #include "synch.h"
  6.  
  7. shared SpinLock s1; 
  8. shared int numAlive; 
  9.  
  10. c() {ProgramDone();}
  11.  
  12. b() 
  13.     {
  14.     int i = 1000000;
  15.  
  16.     while (--i);
  17.     SpinLockAcquire(&s1);
  18.     if (--numAlive == 0)
  19.         c();
  20.     SpinLockRelease(&s1);
  21.     }
  22.  
  23. a() {b();}
  24.  
  25. Main ()
  26.     {
  27.     int i;
  28.  
  29.     SpinLockInit(&s1, "s1");
  30.     numAlive = numProcessors;
  31.     for (i = 0; i < numProcessors; i++)
  32.         (void)ThreadStart(a, NOJOIN, (char *)NULL, 0);
  33.     }
  34.  
  35.  
  36.